package com.easyedu.core.dao;

import com.easyedu.core.entity.po.OpenCourse;
import com.easyedu.core.entity.po.StudentSelect;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author lmr
 **/
@Mapper
public interface StudentSelectDao {

    /**
     * 功能描述: 获取已提交但未审批课程</br>
     * 数据表：open_courses
     *
     * @return : java.util.List<com.easyedu.api.entity.DO.OpenCourse>
     **/
    @Select("select * from open_course where open_courses_id in (select open_courses_id from student_select where is_commit = 2 AND is_effective = 1 group by open_courses_id)")
    List<OpenCourse> getNeedApprovalCourse();

    /**
     * 功能描述:查看所教课程成绩</br>
     * 数据表：student_select
     *
     * @param openCoursesId 1 开放课程唯一id
     * @return : java.util.List<com.easyedu.api.entity.DO.StudentSelect>
     **/
    @Select("select student_number,student_name,course_number,course_name, usual_score,experiment_score,exam_score," +
            "total_score,is_commit from student_select where open_courses_id = #{openCoursesId}")
    List<StudentSelect> getCourseGrade(Long openCoursesId);

    /**
     * 功能描述:设置课程成绩生效
     *
     * @param openCoursesId 1 开放课程唯一id
     * @return : int
     **/
    @Update("update student_select set is_effective = 2 where open_courses_id = #{openCoursesId}")
    int passApprovedCourse(Long openCoursesId);

    /**
     * 功能描述: 根据开放课程唯一id 查询学生列表
     *
     * @param openCoursesId 1 开放课程唯一id
     * @return
     */
    @Select("select * from student_select where open_courses_id = #{openCoursesId}")
    List<StudentSelect> getByOpenCourseId(long openCoursesId);
}
